package com.gillion.tms.entity;

import com.gfa4j.security.data.entity.CrudType;
import com.gfa4j.security.data.entity.IDataPermission;
import com.gillion.business.model.SysRoleAcl;

/**
 * Created by wengms on 2015/4/21.
 */
public class DataPermission implements IDataPermission{

    private String      conditionSql;
    private CrudType    crudType;

    public DataPermission(SysRoleAcl sysRoleAcl){
        this.conditionSql = sysRoleAcl.getConditionSql();
        switch (sysRoleAcl.getCrudType().intValue()){
            case 0:
                crudType = CrudType.INSERT;
                break;
            case 1:
                crudType = CrudType.DELETE;
                break;
            case 2:
                crudType = CrudType.UPDATE;
                break;
            case 3:
                crudType = CrudType.SELECT;
                break;
            default:
                crudType = CrudType.SELECT;
                break;
        }
    }


    @Override
    public String getConditionSql() {
        return this.conditionSql;
    }

    @Override
    public CrudType getCrudType() {
        return this.crudType;
    }

}
